import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class CardDemo {
    public static final String[] Suits = {"♦", "♣", "♥", "♠"};

    public static List<Card> buydesk() {
        List<Card> desk = new ArrayList<>(52);
        for (int i = 0; i < 4; i++) {
            for (int j = 1; j <= 13; j++) {
                String suit = Suits[i];
                Card card = new Card(j, suit);
                desk.add(card);
            }
        }
        return desk;
    }

    public static void brush(List<Card> desk) {
        Random random = new Random();
        for (int i = 0; i < desk.size() - 1; i++) {
            int a = random.nextInt(52);
            swap(desk, i, a);
        }
    }

    private static void swap(List<Card> desk, int i, int a) {
        Card card = desk.get(i);
        desk.set(i, desk.get(a));
        desk.set(a, card);
    }

    public static void getCard(List<Card> desk) {
        List<List<Card>> hands = new ArrayList<>();
        hands.add(new ArrayList<>());
        hands.add(new ArrayList<>());
        hands.add(new ArrayList<>());
        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 3; j++) {
                hands.get(j).add(desk.remove(0));
            }
        }
        System.out.println("hand1"+hands.get(0));
        System.out.println("hand1"+hands.get(1));
        System.out.println("hand1"+hands.get(2));
    }


    public static void main(String[] args) {
        List<Card> desk = buydesk();
        System.out.println("刚买回来的");
        System.out.println(desk);
        System.out.println("洗牌");
        brush(desk);
        System.out.println("洗牌之后");
        System.out.println(desk);
        System.out.println("抓牌");
        getCard(desk);
        System.out.println("剩余的牌"+desk);
    }
}
